<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.textarea.php
 * Type:     function
 * Name:     textarea
 * Purpose:  outputs html for a form textarea
 * -------------------------------------------------------------
 */
function smarty_function_textarea($params, &$smarty) {
    $object = $smarty->_tpl_vars[$params['object']];
	$mapping = $params['object'] . '.' . $params['name'];	
	$readonly = @$params['readonly'] == true;
	
    if(@$params['label'] != '') {
        $html .= '<label>';
        $html .= $params['required'] == true ? '<em>*</em>' : '';
        $html .= $params['label'] . ':</label><br />';
    }
	
	if($readonly === false) {
	    $html .= '<textarea name="' . $mapping . '" id="' . $mapping . '" class="textbox" style="' . @$params['style'] . '">';
	}
    
	$html .= stripslashes($object->$params['name']);
	
	if($readonly === false) {
	    $html .= '</textarea>';
	}
    
    return $html;
}
?>